package com.opennews.openplatform.myspringbootcore.validation

import jakarta.validation.ConstraintValidator
import jakarta.validation.ConstraintValidatorContext

class DateRangeValidator : ConstraintValidator<ValidDateRange, DateRangeValidatable> {
    override fun isValid(value: DateRangeValidatable?, context: ConstraintValidatorContext): Boolean {
        if (value?.getStartDate() == null || value.getEndDate() == null) {
            return true
        }

        return value.getEndDate().isAfter(value.getStartDate())
    }
}
